home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / novia / bin / ping.c < prev    next >
C/C++ Source or Header  |  1999-12-06  |  1KB  |  47 lines

  1. #include <pragma/noviasys_lib.h>
  2. #include <pragma/exec_lib.h>
  3. #include <pragma/dos_lib.h>
  4. #include <stdio.h>
  5. #include <novia/novia_portdata.h>
  6.  
  7. struct Library *NoviaSysBase;
  8.  
  9. void ioprintf(const char *string, ...)
  10. {
  11.     char *buffer=AllocVec(10000,MEMF_ANY|MEMF_CLEAR);
  12.     if (buffer)
  13.     {
  14.         vsprintf(buffer, string, unsigned int(&string + 1));
  15.         Writeio(buffer,-1);
  16.         FreeVec(buffer);
  17.     }
  18. }
  19.  
  20. void main()
  21. {
  22.     if ((NoviaSysBase = OpenLibrary("noviasys.library", 0)))
  23.     {
  24.         struct PortData *cport2;
  25.         struct PortData *cport = (struct PortData *)FindTask(NULL)->tc_UserData;
  26.         if ((cport2 = FindClient(ulong)))
  27.         {
  28.             if (cport2->PortStatus>0)
  29.             {
  30.                 ULONG ticks;
  31.                 timeval tv;
  32.                 double double1;
  33.                 double double2;
  34.                 struct EClockVal eclock;
  35.                 struct EClockVal eclock2;
  36.                 ReadEClock(&eclock);
  37.                 SendMsg(cport2->LocalPort,0,0,MSG_PING,0);
  38.                 Wait(1<<cport->MainPort->mp_SigBit);
  39.                 ticks=ReadEClock(&eclock2)/1000;
  40.                 double1=(double)eclock.ev_lo;
  41.                 double2=(double)eclock2.ev_lo;
  42.                 ioprintf("\n%d, bytes from %d: time=%f ms\n",sizeof(message),cport2->clientconfig.IDNumber,(double2-double1)/(double)ticks);
  43.             }
  44.         }
  45.         CloseLibrary(NoviaSysBase);
  46.     }
  47. }